package com.exception.demo01;

public class Test {
    public static void main(String[] args) {
        int a = 1;
        int b = 0;

        //假设要捕获多个异常：从小到大！

        try {   //try监控区域
            System.out.println(a / b);
        }catch (ArithmeticException e){ //catch(想要捕获的异常类型！) 捕获异常
            System.out.println("程序出现异常，变量b不能为0");
        }catch (Exception e){
            System.out.println("Exception");
        } catch (Error e){
            System.out.println("Error");
        }catch (Throwable e){
            System.out.println("Throwable");
        } finally {  //处理善后工作
            System.out.println("finally");
        }

        //finally 可以不要finally，假设IO,资源类的需要关闭！

    }

    public void a(){
        b();
    }

    private void b() {
        a();
    }
}
